// pages/staff/my/detailhelp.js
const app = getApp()
var CONFIG = require("../../../config/config.js");
var WxParse = require('../../../wxParse/wxParse.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        cid:'',
        centerarr:'',
        type:1,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        // console.log(options);
        var that = this;
        
        var type = options.type;
        that.setData({
            cid: options.cid,
            type: type
        })
        if (Number(type) == 2) {
            wx.setNavigationBarTitle({
                title: '财务规章制度'
            })
        } else {
            wx.setNavigationBarTitle({
                title: '使用指南'
            })
        }
        that.helpContent(options.cid)
    },


    // 分类
    helpContent(cid) {
        wx.showLoading({
            title: '加载中~',
        })
        let that = this;
        var type = that.data.type;
        if (Number(type) == 2) {
            var url = CONFIG.API_HOST + 'crm/My/helpContentCw'
        }else{
            var url = CONFIG.API_HOST + 'crm/My/helpContent'
        }
        wx.request({
            url: url,
            method: 'GET',
            data: {
                tid: cid,
            },
            success: function (res) {
                wx.hideLoading();
                if (res.data.status == 1001 || res.data.status == '1001') {
                    // console.log(res.data);
                    var data = res.data.data;
                    WxParse.wxParse('article', 'html', data.content, that, 5);
                    that.setData({
                        centerarr: data
                    })
                }
            },

        })
    },



    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})